<template>
  <div class="wechat">
    <!-- 卡片视图区域 -->
    <div class="wechat_card">
      <!--搜索框与按钮-->
      <el-row :gutter="20"
              class="wechat_card_head"
              type="flex">
        <el-col :span="5">

          <el-input placeholder="输入车牌号查询"
                    size="medium"
                    v-model="queryInfo.query"
                    clearable
                    @clear="getTableList">
            <el-button slot="append"
                       size="medium"
                       icon="el-icon-search"
                       @click="getTableList"></el-button>
          </el-input>
        </el-col>

        <el-button v-has="'6631'"
                   size="medium"
                   class="btn_head_medium"
                   type="primary"
                   @click="addDialogVisible=true"
                   icon="el-icon-circle-plus-outline">新增</el-button>

        <el-button v-has="'6632'"
                   size="medium"
                   type="danger"
                   @click="deleteRecordByIds"
                   icon="el-icon-remove-outline">删除</el-button>

        <el-select class="select_head_medium"
                   size="medium"
                   v-model="cartTypeValue"
                   @change="selectChange"
                   clearable
                   collapse-tags
                   multiple
                   placeholder="按车辆类型筛选"
                   style="margin-left: 20px;width:180px">
          <el-option label="小汽车"
                     value="0"></el-option>
          <el-option label="面包车"
                     value="1"></el-option>
          <el-option label="货车"
                     value="2"></el-option>
          <el-option label="非机动车"
                     value="3"></el-option>
        </el-select>
        <el-select class="select_head_medium"
                   size="medium"
                   v-model="isChargeValue"
                   @change="selectChange"
                   clearable
                   collapse-tags
                   placeholder="按欠费状态筛选"
                   style="margin-left: 20px;">
          <el-option label="未欠费"
                     value="0"></el-option>
          <el-option label="欠费"
                     value="1"></el-option>
        </el-select>
        <!-- 表格列筛选和导出 -->
        <div class="tools_head">
          <el-popover placement="bottom"
                      trigger="click">
            <el-checkbox-group v-model="tableFilterData.checkBoxList">
              <template v-for="(item, i) in tableFilterData.dataNow">
                <el-checkbox :label="item.attr"
                             :key="i"
                             :checked="item.checked"
                             style="display: block;margin:10px;"
                             @change="filterFunHandle('filter',item.attr,i)">
                  {{item.label}}
                </el-checkbox>
              </template>
            </el-checkbox-group>
            <div slot="reference">
              <el-tooltip content="筛选列"
                          placement="bottom">
                <el-button size="small"
                           icon="el-icon-menu"></el-button>
              </el-tooltip>
            </div>
            <el-button size="small"
                       type="text"
                       @click="filterFunHandle('allchecked')">全选</el-button>
            <el-button size="small"
                       type="text"
                       @click="filterFunHandle('cancel')">取消全选</el-button>
          </el-popover>

          <el-tooltip content="导出excel"
                      placement="bottom">
            <el-button size="small"
                       icon="el-icon-download"
                       style="margin-left: 10px"
                       @click="exportDataToExcel"></el-button>
          </el-tooltip>
        </div>

      </el-row>
      <!-- 表格区域 -->
      <el-table :data="tableFilterData.dataList"
                style="width: 100%"
                height="85%"
                border
                stripe
                size="small"
                :key="Math.random()"
                :header-cell-style="{ textAlign: 'center' }"
                :cell-style="{ textAlign: 'center' }"
                @selection-change="handleSelectionChange">
        <el-table-column type="selection">
        </el-table-column>
        <!-- 序号列 -->
        <el-table-column type="index"
                         label="序号"></el-table-column>
        <!-- 依次渲染表格的每列 -->
        <template v-for="(col,index) in tableFilterData.dataNow">
          <!-- 如果当前列的attr为普通类型，渲染内容即可 -->
          <el-table-column :key="index+'2'"
                           v-if="col.checked===true &&col.attr!=='state' && col.attr!=='type'&& col.attr!=='brand'&& col.attr!=='cartType'&& col.attr!=='masterId'&& col.attr!=='masterPhone'&& col.attr!=='payTime'&& col.attr!=='addTime'&& col.attr!=='memo'"
                           align="center"
                           :prop="col.attr"
                           :label="col.label">
          </el-table-column>
          <!-- 如果当前列的attr为state，渲染为switch开关形式 -->
          <el-table-column :key="index"
                           v-if="col.checked===true &&col.attr==='state'"
                           :label="col.label"
                           :filters="[{ text: '未欠费', value: 0 }, { text: '已欠费', value: 1 }]"
                           :filter-method="filterState"
                           filter-placement="bottom-end"
                           width="120">
            <template slot-scope="scope">
              <el-switch v-model="scope.row.state"
                         @change="switchStateChanged(scope.row)">
              </el-switch>
            </template>
          </el-table-column>
          <!-- 如果当前列的attr为brand，将brand内容渲染为标签形式 -->
          <el-table-column :key="index"
                           v-if="col.checked===true &&col.attr==='brand'"
                           :label="col.label"
                           :prop="col.attr"
                           width="120">
            <template slot-scope="scope">
              <el-tag size="mini">{{scope.row.brand}}</el-tag>
            </template>
          </el-table-column>
          <!-- 如果当前列的attr为cartType，渲染为标签形式 -->
          <el-table-column :key="index"
                           v-if="col.checked===true &&col.attr==='cartType'"
                           :label="col.label"
                           :prop="col.attr"
                           :filters="[{ text: '小汽车', value: 0 }, { text: '面包车', value: 1 }, { text: '货车', value: 2 }, { text: '非机动车', value: 3 }]"
                           :filter-method="filterType"
                           filter-placement="bottom-end"
                           width="120">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.cartType == '0'"
                      size="mini">小汽车</el-tag>
              <el-tag v-if="scope.row.cartType == '1'"
                      type="warning"
                      size="mini">面包车</el-tag>
              <el-tag v-if="scope.row.cartType == '2'"
                      type="danger"
                      size="mini">货车</el-tag>
              <el-tag v-if="scope.row.cartType == '3'"
                      type="success"
                      size="mini">非机动车</el-tag>
            </template>
          </el-table-column>

          <!-- 长度限定 -->
          <el-table-column :key="index+'a'"
                           v-if="col.checked===true && col.attr=='payTime' "
                           align="center"
                           :prop="col.attr"
                           :label="col.label"
                           width="180">
          </el-table-column>
          <el-table-column :key="index+'a'"
                           v-if="col.checked===true && col.attr=='addTime' "
                           align="center"
                           :prop="col.attr"
                           :label="col.label"
                           width="180">
          </el-table-column>
          <el-table-column :key="index+'a'"
                           v-if="col.checked===true && col.attr=='masterId' "
                           align="center"
                           :prop="col.attr"
                           :label="col.label"
                           width="180">
          </el-table-column>
          <el-table-column :key="index+'a'"
                           v-if="col.checked===true && col.attr=='masterPhone' "
                           align="center"
                           :prop="col.attr"
                           :label="col.label"
                           width="130">
          </el-table-column>
          <el-table-column :key="index+'a'"
                           v-if="col.checked===true && col.attr=='memo' "
                           align="center"
                           :prop="col.attr"
                           :label="col.label"
                           width="150"
                           show-overflow-tooltip>
          </el-table-column>
        </template>

        <el-table-column label="操作"
                         width="180px"
                         fixed="right">
          <template slot-scope="scope">
            <!-- 编辑按钮 -->
            <el-button v-has="'6633'"
                       type="primary"
                       icon="el-icon-edit"
                       size="mini"
                       @click="showEditDialog(scope.row.id)"></el-button>
            <!-- 删除按钮 -->
            <el-button v-has="'6634'"
                       type="danger"
                       icon="el-icon-delete"
                       size="mini"
                       @click="deleteRecordById(scope.row.id)"></el-button>

          </template>
        </el-table-column>

      </el-table>

      <!-- 分页 -->
      <el-pagination @size-change="handleSizeChange"
                     @current-change="handleCurrentChange"
                     :current-page="this.queryInfo.pageNum"
                     :page-sizes="[3, 7, 15, 20, 30]"
                     :page-size="this.queryInfo.pageSize"
                     layout="total, sizes, prev, pager, next, jumper"
                     :total="total"></el-pagination>

      <!-- 添加记录的对话框 -->
      <el-dialog title="添加车辆档案信息"
                 :visible.sync="addDialogVisible"
                 @close="addDialogClosed"
                 width="50%">
        <!-- 内容主体区 -->
        <el-form :model="addForm"
                 :rules="addFormRules"
                 ref="addFormRef"
                 label-width="110px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="车牌号"
                            prop="cartId">
                <el-input v-model="addForm.cartId"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="品牌"
                            prop="brand">
                <el-input v-model="addForm.brand"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="型号"
                            prop="model">
                <el-input v-model="addForm.model"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="车辆类型"
                            prop="cartType">
                <el-input v-model="addForm.cartType"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="排量"
                            prop="emissions">
                <el-input v-model="addForm.emissions"
                          placeholder="单位：升"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="房间ID"
                            prop="roomId">
                <el-input v-model="addForm.roomId"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="业主ID"
                            prop="risidentId">
                <el-input v-model="addForm.risidentId"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="车主身份证号码"
                            prop="masterId">
                <el-input v-model="addForm.masterId"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="车主姓名"
                            prop="masterName">
                <el-input v-model="addForm.masterName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="车主电话"
                            prop="masterPhone">
                <el-input v-model="addForm.masterPhone"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="欠费时长"
                            prop="attr">
                <el-input v-model="addForm.attr"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="缴费截止日期"
                            prop="payTime">
                <el-date-picker v-model="addForm.payTime"
                                type="date"
                                placeholder="请选择缴费截止日期"
                                format="yyyy 年 MM 月 dd 日"
                                value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item label="备注"
                        prop="memo">
            <el-input type="textarea"
                      v-model="addForm.memo"></el-input>
          </el-form-item>

        </el-form>
        <!-- 底部区域 -->
        <span slot="footer"
              class="dialog-footer">
          <el-button @click="addDialogVisible = false">取 消</el-button>
          <el-button type="primary"
                     @click="addRecord">确 定</el-button>
        </span>
      </el-dialog>
      <!-- 修改记录对话框 -->
      <el-dialog title="修改车辆档案信息"
                 :visible.sync="editDialogVisible"
                 width="50%"
                 @close="editDialogClosed">
        <el-form :model="editForm"
                 :rules="editFormRules"
                 ref="editFormRef"
                 label-width="110px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="车牌号"
                            prop="cartId">
                <el-input v-model="editForm.cartId"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="品牌"
                            prop="brand">
                <el-input v-model="editForm.brand"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="型号"
                            prop="model">
                <el-input v-model="editForm.model"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="车辆类型"
                            prop="cartType">
                <el-input v-model="editForm.cartType"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="排量"
                            prop="emissions">
                <el-input v-model="editForm.emissions"
                          placeholder="单位：升"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="房间ID"
                            prop="roomId">
                <el-input v-model="editForm.roomId"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="业主ID"
                            prop="risidentId">
                <el-input v-model="editForm.risidentId"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="车主身份证号码"
                            prop="masterId">
                <el-input v-model="editForm.masterId"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="车主姓名"
                            prop="masterName">
                <el-input v-model="editForm.masterName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="车主电话"
                            prop="masterPhone">
                <el-input v-model="editForm.masterPhone"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="欠费时长"
                            prop="attr">
                <el-input v-model="editForm.attr"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="缴费截止日期"
                            prop="payTime">
                <el-date-picker v-model="editForm.payTime"
                                type="date"
                                placeholder="请选择缴费截止日期"
                                format="yyyy 年 MM 月 dd 日"
                                value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item label="备注"
                        prop="memo">
            <el-input type="textarea"
                      v-model="editForm.memo"></el-input>
          </el-form-item>

        </el-form>
        <span slot="footer"
              class="dialog-footer">
          <el-button @click="editDialogVisible = false">取 消</el-button>
          <el-button type="primary"
                     @click="editRecordInfo">确 定</el-button>
        </span>
      </el-dialog>

    </div>
  </div>
</template>
<script>
import {
  getList,
  add,
  deleteSelected,
  deleteCurrent,
  getEditInfo,
  edit,
  getDetail,
  modifySwitch,
} from "@/api/logistics/logisticsGreen.js";
export default {
  data () {
    return {
      // 表格列筛选数据
      tableFilterData: {
        dataList: [

        ],
        dataNow: [
          { label: "	序号	", attr: "id", checked: false },
          { label: "	车牌号	", attr: "cartId", checked: true },
          { label: "	品牌	", attr: "brand", checked: false },
          { label: "	型号	", attr: "model", checked: false },
          { label: "	车辆类型	", attr: "cartType", checked: true },
          { label: "	排量（升）	", attr: "emissions", checked: false },
          // { label: "	房间id	", attr: "roomId", checked: false },
          { label: "	房间号	", attr: "roomId", checked: false },
          // { label: "	业主id	", attr: "risidentId", checked: false },
          { label: "	业主	", attr: "risidentName", checked: false },
          { label: "	车主身份证号码	", attr: "masterId", checked: false },
          { label: "	车主姓名	", attr: "masterName", checked: true },
          { label: "	车主电话	", attr: "masterPhone", checked: false },
          { label: "	欠费时长(分钟)	", attr: "arrearsTime", checked: true },
          { label: "	缴费截止日期	", attr: "payTime", checked: true },
          // { label: "	社区id	", attr: "communityId", checked: false },
          { label: "	添加人id	", attr: "addUserId", checked: false },
          { label: "	添加人	", attr: "addUserName", checked: false },
          { label: "	添加时间	", attr: "addTime", checked: false },
          { label: "	备注	", attr: "memo", checked: true },

        ],

        checkLabels: [], // 筛选列显示多选框数据
        checkBoxList: [], // 筛选列数据
        indexTwo: 0,
      },
      // 记录列表分页区的参数
      queryInfo: {
        //搜索条件
        query: "",
        // 当前页码
        pageNum: 1,
        //每页显示条数
        pageSize: 7,
      },
      total: 0,


      // 控制添加记录对话框的显示与隐藏
      addDialogVisible: false,
      // 添加记录的表单数据
      addForm: {
        id: "",
        cartId: "",
        brand: "",
        model: "",
        cartType: "",
        emissions: "",
        roomId: "",
        risidentId: "",
        masterId: "",
        masterName: "",
        masterPhone: "",
        arrearsTime: "",
        payTime: "",
        communityId: "",
        addUserId: "",
        addTime: "",
        memo: "",

      },
      // 添加表单校验规则
      addFormRules: {},


      // 控制修改用户对话框的显示与隐藏
      editDialogVisible: false,
      // 查询到的用户信息
      editForm: {},
      // 编辑表单校验规则
      editFormRules: {},


      // 控制详细信息抽屉的显示与隐藏
      drawerVisible: false,
      // 详细信息的表单数据
      detailForm: {},
      // 被选中的记录id
      selectedList: [],
      selectedStr: {
        ids: "",
      },
      deleteNow: {
        ids: "",
      },
      cartTypeValue: [],
      isChargeValue: '',
    }
  },
  created () {
    this.getTableList();
  },
  methods: {
    // 获取列表信息
    async getTableList () {
      this.queryInfo = this.getQueryCondition()
      const { data: res } = await this.$http.get("ParkcartinfoAction/getBasicInfos", { params: this.queryInfo })
      if (!res.success) return this.$message.error('获取表格数据失败')
      // this.$message.success('获取列表数据成功')
      this.tableFilterData.dataList = res.rows
      this.total = res.total
      console.log(res)


    },
    //获取工具栏的各类查询条件：搜索框关键词、筛选框值等
    getQueryCondition () {
      //搜索框筛选
      var search = `parkcartinfo.cartId like "%${this.queryInfo.query}%"`;

      // 下拉框筛选
      var isCharge = '';
      if (this.isChargeValue !== '') {
        if (this.isChargeValue == '0') {  //未欠费
          isCharge += ` and parkcartinfo.arrearsTime=0`;
        } else {  //欠费
          isCharge += ` and parkcartinfo.arrearsTime!=0`;
        }

      }

      var cartTypeList = '';
      if (this.cartTypeValue.length != 0) {
        cartTypeList += ` and(`;
        for (var i in this.cartTypeValue) {
          cartTypeList += ` parkcartinfo.cartType='${this.cartTypeValue[i]}'`
          if (i != this.cartTypeValue.length - 1) {
            cartTypeList += ` or `
          }
        }
        cartTypeList += `)`
      }
      this.queryInfo.condition = `${search}${isCharge}${cartTypeList}`
      return this.queryInfo;
    },
    //工具栏的各种下拉框筛选监听
    async selectChange () {
      this.getTableList()
    },


    // 监听多选框选中的所有记录
    handleSelectionChange (val) {
      this.selectedList = val.map(item => {
        return item.id;
      })
    },
    // 监听pageSize改变的事件
    handleSizeChange (newSize) {
      this.queryInfo.pageSize = newSize
      this.getTableList()
    },
    // 监听页码值改变的事件
    handleCurrentChange (newPage) {
      this.queryInfo.pageNum = newPage
      this.getTableList()
    },
    // 监听添加对话框的关闭事件
    addDialogClosed () {
      this.$refs.addFormRef.resetFields()
    },
    // 监听修改对话框的关闭
    editDialogClosed () {
      this.$refs.editFormRef.resetFields()
    },
    // 表头列筛选功能
    filterFunHandle (type, currentItem, index) {
      if (type === 'filter') { // 筛选列
        if (event.target.checked === false) {
          this.tableFilterData.dataNow.forEach((item, index, arr) => {
            if (item.attr === currentItem) {
              return item.checked = false
            }
          })
        } else {
          this.tableFilterData.dataNow.forEach((item, index, arr) => {
            if (item.attr === currentItem) {
              return item.checked = true
            }
          })
        }
      } else if (type === 'allchecked') { // 全选
        if (this.tableFilterData.checkLabels.length === 0) {
          this.tableFilterData.dataNow.forEach((result) => {
            this.tableFilterData.checkLabels.push(result.attr)
          })
          this.tableFilterData.checkBoxList = this.tableFilterData.checkLabels // 复选框置为复选所有值，全部选择    
        } else {
          this.tableFilterData.checkBoxList = this.tableFilterData.checkLabels // 复选框置为复选所有值，全部选择
        }
        this.tableFilterData.dataNow.forEach((item, index, arr) => {
          item.checked = true
        })
      } else if (type === 'cancel') { // 取消全选
        this.tableFilterData.checkBoxList = [] // 复选框置为空，全部不选择
        this.tableFilterData.dataNow.forEach((item, index, arr) => {
          item.checked = false
        })
      }
    },
    // 状态筛选（开关筛选）
    filterState (value, row) {
      return row.state === value;
    },
    // 类型筛选（标签筛选）
    filterType (value, row) {
      return row.type === value;
    },






    // 添加记录
    addRecord () {
      this.$refs.addFormRef.validate(async valid => {
        if (!valid) return
        const { data: res } = await this.$http.post("ParkcartinfoAction/addObject", this.addForm)
        if (!res.success) return this.$message.error('添加失败')
        this.$message.success('添加记录成功！')
        // 隐藏添加记录的对话框
        this.addDialogVisible = false
        // 重新获取记录列表数据
        this.getTableList()
      })
    },
    // 删除（批量）
    async deleteRecordByIds () {
      // 弹框询问用户是否删除数据
      const confirmResult = await this.$confirm('此操作将永久删除记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).catch(err => err)
      // 如果用户确认删除，返回值为字符串confirm
      // 如果用户取消删除，返回值未字符串cancel
      // console.log(confirmResult)
      if (confirmResult !== 'confirm') {
        return this.$message.info('已经取消删除')
      }
      // 将selectList数组处理成字符串形式并赋值给selectStr的ids属性
      var str = ""
      for (var i = 0; i < this.selectedList.length - 1; i++) {
        str += this.selectedList[i] + ",";
      }
      str += this.selectedList[this.selectedList.length - 1]
      this.selectedStr.ids = str

      const { data: res } = await this.$http.post("ParkcartinfoAction/deleteByIds", this.selectedStr)
      if (!res.success) return this.$message.error('删除记录失败！')
      this.$message.success('删除记录成功！')
      this.getTableList()

    },
    // 查看修改记录（当前记录）
    async showEditDialog (id) {
      const { data: res } = await this.$http.post("ParkcartinfoAction/getObjectById", { id })
      if (!res.success)
        return this.$message.error('获取信息失败')
      this.editForm = res.rows[0]
      this.editDialogVisible = !this.editDialogVisible

    },
    // 确认修改
    editRecordInfo () {
      this.$refs.editFormRef.validate(async valid => {
        if (!valid) return
        // 发起修改记录信息的数据请求
        const { data: res } = await this.$http.post("ParkcartinfoAction/updateNoNull", this.editForm)
        if (!res.success) return this.$message.error('更新信息失败！')
        // 关闭对话框
        this.editDialogVisible = false
        // 刷新数据列表
        this.getTableList()
        // 提示修改成功
        this.$message.success('更新信息成功！')
      })
    },
    // 删除（当前记录）
    async deleteRecordById (id) {
      // 弹框询问用户是否删除数据
      const confirmResult = await this.$confirm('此操作将永久删除记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).catch(err => err)
      // 如果用户确认删除，返回值为字符串confirm
      // 如果用户取消删除，返回值未字符串cancel
      // console.log(confirmResult)
      if (confirmResult !== 'confirm') {
        return this.$message.info('已经取消删除')
      }
      this.deleteNow.ids = id

      const { data: res } = await this.$http.post("ParkcartinfoAction/deleteByIds", this.deleteNow)
      if (!res.success) return this.$message.error('删除记录失败！')
      this.$message.success('删除记录成功！')
      this.getTableList()

    },

    // 修改switch开关状态（当前记录）
    async switchStateChanged (recordinfo) {
      console.log(recordinfo)
      const { data: res } = await this.$http.post("ParkcartinfoAction/updateNoNull", recordinfo)
      if (!res.success) {
        recordinfo.state = !recordinfo.state
        return this.$message.error('更新信息失败！')
      }
      // 关闭对话框
      this.editDialogVisible = false
      // 刷新数据列表
      this.getTableList()
      // 提示修改成功
      this.$message.success('更新信息成功！')
    },
    // 导出表格
    async exportDataToExcel () {
      // 弹框询问用户是否删除数据
      const confirmResult = await this.$confirm('此操作将把数据为导出表格, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).catch(err => err)
      // 如果用户确认删除，返回值为字符串confirm
      // 如果用户取消删除，返回值未字符串cancel
      // console.log(confirmResult)
      if (confirmResult !== 'confirm') {
        return this.$message.info('已经取消删除')
      }

      const { date: res } = await this.$http.post("ParkcartinfoAction/exportDataToExcel")
      if (!res.success) return this.$message.error('导出表格失败')
      this.$message.success('导出表格成功')
    },


  }

}


</script>
<style scoped>
.el-table {
  font-size: 13px;
}
.el-pagination {
  text-align: left;
  padding-top: 20px;
}
</style>